package org.ivwsqii.prototype.register;

import java.util.HashMap;
import java.util.Map;

public class PrototypeManager {

	private static Map<String,Prototype> map = new HashMap<>();

	private PrototypeManager() {}

	public synchronized static void setPrototype(String name,Prototype type) {
		map.put(name, type);
	}
	public synchronized static void removePrototype(String name) {
		map.remove(name);
	}
	public synchronized static Prototype getPrototype(String name) throws Exception {

		Prototype prototype = map.get(name);
		if(prototype == null) {
			throw new NullPointerException("您希望获取的原型还没有注册或已被销毁");
		}
		return prototype;

	}

}
